package com.ja.openchat.ui.message;

import androidx.recyclerview.widget.DiffUtil;

import com.zy.openchat.core.model.message.ChatInfo;

import java.util.List;

public class SearchAvatarDiffCallBack extends DiffUtil.Callback{

    private List<ChatInfo> mOldDatas, mNewDatas;

    public SearchAvatarDiffCallBack(List<ChatInfo> oldDatas, List<ChatInfo> newDatas) {
        this.mOldDatas = oldDatas;
        this.mNewDatas = newDatas;
    }


    @Override
    public int getOldListSize() {
        return mOldDatas != null ? mOldDatas.size() : 0;
    }

    // 新数据集 size
    @Override
    public int getNewListSize() {
        return mNewDatas != null ? mNewDatas.size() : 0;
    }


    @Override
    public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
        return mOldDatas.get(oldItemPosition).isMessageEqual(mNewDatas.get(newItemPosition));
    }

    @Override
    public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {

        return mOldDatas.get(oldItemPosition).isAvaterDownloadEqual(mNewDatas.get(newItemPosition));
    }
}
